package com.guo.hui.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guo.hui.dao.ponal.UserMapper;
import com.guo.hui.model.ponal.User;
import com.guo.hui.page.PageParam;
import com.guo.hui.service.UserService;
import com.guo.hui.util.UtilDate;

@Service("userService")
public class UserServiceImpl implements UserService {

	@Autowired
	private UserMapper userDao;

	public void saveUser(User user) {
		String time = UtilDate.datetoString(new Date(), "yyyy-MM-dd");// 日期转化字符串
		user.setCreateDate(time);
		user.setModifyDate(new Date());
		userDao.insert(user);

	}

	public User loginAuth(String username, String password) {
		return userDao.loginAuth(username, password);
	}

	public void updateUser(User user) {
		user.setModifyDate(new Date());
		userDao.update(user);
	}

	public PageInfo<User> selectByMapPage(PageParam pageParm) {
		PageHelper.startPage(pageParm.getPage(), pageParm.getPageSize());
		List<User> list = userDao.selectByMap(pageParm.getSearchContent());
		return new PageInfo<User>(list);
	}

}
